package com.itboye.textileexpes.repository;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.reflect.TypeToken;
import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.interfaces.IUserRepository;
import com.itboye.textileexpes.beans.AppUpdateBean;
import com.itboye.textileexpes.beans.KefuBeans;
import com.itboye.textileexpes.beans.NewsKefuBeans;
import com.itboye.textileexpes.beans.PersonDataBean;
import com.itboye.textileexpes.beans.UserBean;
import com.itboye.textileexpes.interfaces.IAppUpdate;
import com.itboye.textileexpes.json.ByJsonRequest.Builder;
import com.itboye.textileexpres.base.BaseErrorListener;
import com.itboye.textileexpres.base.BaseNetRepository;
import com.itboye.textileexpres.base.BaseSuccessReqListener;

public class APPUpdateRepository extends BaseNetRepository implements
		IAppUpdate<AppUpdateBean> {
	// 获取app版本
	public static final String GetVersion = "By_Config_app";
	public static final String PassWold = "By_User_updatePwd";
	//客服测试
	public static final String Kefu = "By_Customer_all";

	public APPUpdateRepository(ICompleteListener listener) {
		// TODO Auto-generated constructor stub
		super(listener);
	}

	@Override
	public void add(AppUpdateBean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(AppUpdateBean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(AppUpdateBean model) {
		// TODO Auto-generated method stub
	
	}

	@Override
	public void getInfo(AppUpdateBean model) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<AppUpdateBean>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("api_ver", apiVer);
		map.put("app_type", "android");

		(new Builder<AppUpdateBean>())
				.setTypeVerParamsAndReturnClass(GetVersion, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<AppUpdateBean>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();

	}

	@Override
	public List<AppUpdateBean> query(AppUpdateBean model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void onUpdate(String code, String country, String mobile,
			String password) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("api_ver", "101");
		map.put("app_type", "android");
		map.put("code", code);
		map.put("country", country);
		map.put("mobile", mobile);
		map.put("password", password);

		(new Builder<String>())
				.setTypeVerParamsAndReturnClass(PassWold, "101", map, type)
				.requestListener(
						new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	@Override
	public void onKefu() {
		// TODO Auto-generated method stub
		Type type = new TypeToken<List<NewsKefuBeans>>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("api_ver", "100");
		map.put("app_type", "android");
	

		(new Builder<List<NewsKefuBeans>>())
				.setTypeVerParamsAndReturnClass(Kefu, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<List<NewsKefuBeans>>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

}
